--    Author    : ChenErHao
--    Name      : ODS.DEPB.HQL
--    Functions : 
--    Purpose   : Daily saving the variation data from stg
--    Revisions or Comments
--    VER        DATE        AUTHOR           DESCRIPTION
--   ---------  ----------  ---------------  ------------------------------------
--    1.0        2019-12-04  ChenErHao       1.CREATE THE PROCEDURE
--

INSERT OVERWRITE TABLE ODS.DEPB PARTITION (DATA_DATE = '#V_DATA_DATE#',DATA_SRC_ORG) 
SELECT 
     FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd HH:mm:ss') AS BATCH_DATE
    ,DATA_ORG_CODE
    ,CUSTOMER_TYPE
    ,ACCOUNT_CODE
    ,DEP_AGREEMENT_CODE
    ,PRODUCT_CATEGORY
    ,DEP_AGREEMENT_SDATE
    ,DEP_AGREEMENT_EDATE
    ,DEP_CUR_TYPE
    ,DEP_BALANCE
    ,RATE_FIXED_FLOAT
    ,RATE_LEVEL
    ,DATA_SRC_ORG 
FROM STG.DEPB
WHERE DATA_DATE='#V_DATA_DATE#'

UNION ALL

SELECT 
     FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd HH:mm:ss') AS BATCH_DATE
    ,DATA_ORG_CODE
    ,CUSTOMER_TYPE
    ,ACCOUNT_CODE
    ,DEP_AGREEMENT_CODE
    ,PRODUCT_CATEGORY
    ,DEP_AGREEMENT_SDATE
    ,DEP_AGREEMENT_EDATE
    ,DEP_CUR_TYPE
    ,DEP_BALANCE
    ,RATE_FIXED_FLOAT
    ,RATE_LEVEL 
    ,DATA_SRC_ORG
FROM STG.DEPB_13  
WHERE DATA_DATE='#V_DATA_DATE#'
;